package com.topisv.tms.utils.http;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.topisv.tms.service.vo.invoice.InvoiceReturnModel;
import com.topisv.tms.service.work.InvoicePrintService;

@Component
public class SynchroInvoicePrinter implements Runnable {
	private static final Logger log = LoggerFactory.getLogger(SynchroInvoicePrinter.class);
	
	@Autowired
	private InvoicePrintService invoicePrintService;

	@Override
	public void run() {
		while (true) {
			try {
				InvoiceReturnModel invoiceReturnModel = SynchroShippedBatchQueue.takeInvoicePrinterModel();
				if (invoiceReturnModel != null) {
					invoicePrintService.updateInvoice(invoiceReturnModel);
				}
			} catch (Exception e) {
				log.error("error.", e);
			}
		}
	}
}
